﻿@{
    Layout = "";
}

@model CheckoutAttributeValueModel

<form id="ValueCreatePopup" asp-area="@Constants.AreaAdmin" asp-controller="CheckoutAttribute" asp-action="ValueCreatePopup"
      asp-route-checkoutAttributeId="@HtmlExtensions.HtmlEncodeSafe(Context.Request.Query["checkoutAttributeId"])">
    <div class="row">
        <div class="col-md-12">
            <div class="x_panel light form-fit">
                <div class="x_title">
                    <div class="caption">
                        <i class="fa fa-list-alt"></i>
                        @Loc["Admin.Orders.CheckoutAttributes.Values.AddNew"]
                    </div>
                    <div class="actions">
                        <vc:admin-widget widget-zone="checkout_attribute_value_details_buttons" additional-data="null"/>
                    </div>
                </div>
                <div class="x_content form">
                    <partial name="Partials/CreateOrUpdateValue" model="Model"/>
                </div>
            </div>
        </div>
    </div>
    <script>
        var mfp = $.magnificPopup.instance;
            $("#ValueCreatePopup").submit(function (e) {
                e.preventDefault();
                var form = $(this);
                var url = form.attr('action');
                $.ajax({
                    type: "POST",
                    url: url,
                    data: form.serialize(),
                    success: function (data) {
                        if (data == "") {
                            mfp.close();
                            $('#btnRefresh').click();
                        } else {
                            $.magnificPopup.open({
                                items: {
                                    src: data,
                                    type: 'inline'
                                },
                                callbacks: {
                                    open: function () {
                                        $('.mfp-wrap').removeAttr('tabindex');
                                    }
                                }
                            });
                        }
                    }
                });
            });
    </script>
</form>